#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 1e6 + 10, INF = 0x3f3f3f3f;

ll n, q;
ll block, t;
ll st[N], ed[N], pos[N];
ll a[N], b[N], add[N];

void init()
{
    block = sqrt(n);
    t = (n + block - 1) / block;
    for (ll i = 1;i <= t;i++) {
        st[i] = (i - 1) * block + 1;
        ed[i] = i * block;
    }
    ed[t] = n;
    for (ll i = 1;i <= n;i++)
        pos[i] = (i - 1) / block + 1;
}

void change(ll l, ll r, ll d)
{
    ll p = pos[l], q = pos[r];
    if (p == q) {
        for (ll i = l;i <= r;i++)  a[i] += d;
        for (ll i = st[p];i <= ed[p];i++) b[i] = a[i];
        sort(b + st[p], b + ed[p] + 1);
    } else {
        for (ll i = p + 1;i <= q - 1;i++) add[i] += d;

        for (ll i = l;i <= ed[p];i++) a[i] += d;
        for (ll i = st[p];i <= ed[p];i++) b[i] = a[i];
        sort(b + st[p], b + ed[p] + 1);

        for (ll i = st[q];i <= r;i++) a[i] += d;
        for (ll i = st[q];i <= ed[q];i++) b[i] = a[i];
        sort(b + st[q], b + ed[q] + 1);
    }
}

ll ask(ll l, ll r, ll c)
{
    ll ans = 0;
    ll p = pos[l], q = pos[r];
    if (p == q) {
        for (ll i = l;i <= r;i++) ans += a[i] >= (c - add[p]);
    } else {
        for (ll i = p + 1;i <= q - 1;i++) {
            ll cnt = b + ed[i] - lower_bound(b + st[i], b + ed[i] + 1, c - add[i]) + 1;
            ans += cnt;
        }
        for (ll i = l;i <= ed[p];i++) ans += a[i] >= (c - add[p]);
        for (ll i = st[q];i <= r;i++) ans += a[i] >= (c - add[q]);
    }
    return ans;
}

void solve()
{
    cin >> n >> q; init();
    for (ll i = 1;i <= n;i++) { cin >> a[i];b[i] = a[i]; }
    for (ll i = 1;i <= t;i++) sort(b + st[i], b + ed[i] + 1);

    char op;ll l, r, d;
    while (q--) {
        cin >> op;
        if (op == 'M') {
            cin >> l >> r >> d;
            change(l, r, d);
        } else {
            cin >> l >> r >> d;
            cout << ask(l, r, d) << '\n';
        }
    }
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}